package by.bucha.testproject.fragments;

import by.bucha.testproject.R;
import by.bucha.testproject.imageLoader.ImageLoaderCallback;
import by.bucha.testproject.imageLoader.ImageLoaderData;
import by.bucha.testproject.utils.TaskApplication;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;

public class FullScreenImageFragment extends Fragment {

	public FullScreenImageFragment() {
	}

	public static String EXTRA_PHOTO_PATH = "photo path";

	private String mPath;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Bundle bundle = this.getArguments();
		mPath = bundle.getString(EXTRA_PHOTO_PATH);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);

	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.view_fragment_full_screen_image,
				container, false);

		ImageView imageView = (ImageView) view
				.findViewById(R.id.view_full_screen_image_fragment_image);
		int height = imageView.getLayoutParams().height;
		int width = imageView.getLayoutParams().width;
		TaskApplication.getImageLoader().bind(
				new ImageLoaderData(imageView, mPath, width, height),
				new ImageLoaderCallback() {

					@Override
					public void onSucsess() {
						// TODO Auto-generated method stub

					}

					@Override
					public void onError(Exception e) {

						String warning = getActivity()
								.getApplicationContext()
								.getResources()
								.getString(
										R.string.full_screen_image_fragment_strings_errore);

						Toast.makeText(getActivity().getApplicationContext(),
								warning + " : " + e.getMessage(),
								Toast.LENGTH_SHORT).show();
					}
				});
		return view;
	}
}
